package com.hns.can.mainte.web;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hns.can.base.entity.SysUserEntity;
import com.hns.can.common.domain.GridPage;
import com.hns.can.common.web.BaseController;
import com.hns.can.mainte.entity.CommMftCopaEntity;
import com.hns.can.mainte.service.ReportServiceManualService;
import com.hns.frame.mybatis.Pagination;

/**
 * 报表-机务报表-车辆体检-维修手册
 * @author:yecb
 * @email:lps00@163.com
 * @version Revision 2.0.0
 */
@Controller
@RequestMapping("/reportServiceManual")
public class ReportServiceManualController extends BaseController  {
    
    @Autowired
    private ReportServiceManualService reportServiceManualService;
    
    /**
     * 修改故障信息对照表
     * @param entity
     * @return
     * @author:yecb
     * @throws Exception 
     * @email:lps00@163.com
     */
    @RequestMapping("/uptCommMftCopaEntity")
    @ResponseBody
    public Object  uptCommMftCopaEntity(CommMftCopaEntity entity) throws Exception {
    	SysUserEntity user = getCurrentUser().getUser();
        entity.setUpdateUser(user.getAcctName());
        entity.setUpdateTime(new Date());
        reportServiceManualService.uptCommMftCopaEntity(entity,user);
        return this.getReturnResult();
    }
  
    
  	/**
  	 * 根据ID获取故障信息
  	 * @param mftTypeCode
  	 * @return
  	 * @throws Exception
  	 * @author:yecb
  	 * @email:lps00@163.com
  	 */
    @RequestMapping("/getCommMftCopaById")
    @ResponseBody
    public Object  getCommMftCopaById(@RequestParam("mftTypeCode") String mftTypeCode) throws Exception{
        CommMftCopaEntity entity =reportServiceManualService.getCommMftCopaById(mftTypeCode);
        return this.getReturnResult(entity);
    }
    
	/**
  	 * 根据故障名称获取故障信息
  	 * @param mftTypeName
  	 * @return
  	 * @throws Exception
  	 * @author:yecb
  	 * @email:lps00@163.com
  	 */
    @RequestMapping("/getCommMftCopaByMftName")
    @ResponseBody
    public Object  getCommMftCopaByMftName(@RequestParam("mftTypeCode") String mftTypeName) throws Exception{
        CommMftCopaEntity entity =reportServiceManualService.getCommMftCopaByName(mftTypeName);
        return entity;
    }
   
    /**
     * 删除故障对照信息
     * @param entity
     * @return
     * @author:yecb
     * @email:lps00@163.com
     */
    @RequestMapping("/delCommMftCopaEntity")
    @ResponseBody
    public Object delCommMftCopaEntity(CommMftCopaEntity entity){
    	reportServiceManualService.delCommMftCopaEntity(entity);
    	return this.getReturnResult();
    }
    /**
     * 查找故障列表信息
     * @return
     * @author:yecb
     * @email:lps00@163.com
     */
    @RequestMapping("/getMftInfoList")
    @ResponseBody
    public Object getMftInfoList(CommMftCopaEntity entity) throws Exception {
    	Pagination page = reportServiceManualService.getMftInfoList(entity, getCurrentUser().getUser());
    	GridPage grid = new GridPage(page);
    	return getReturnResult(grid);
    }
    /**
     * 查找到当前登录公司的ECU节点列表
     * @return
     * @author:yecb
     * @email:lps00@163.com
     */
    @RequestMapping("/getEcuTypeInfoList")
    @ResponseBody
    public Object getEcuTypeInfoList() {
    	List<CommMftCopaEntity> list =  reportServiceManualService.getEcuTypeInfoList(getCurrentUser().getUser());
    	return getReturnResult(list);
    }
}
